<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>cascade.html</title>
		<script type="text/javascript">
			var xmlreq;
			function sendRequest(){
				//创建XMLHttpRequest对象
				if(window.XMLHttpRequest){
					xmlreq=new XMLHttpRequest();
				}else{
					try{
						xmlreq= new ActiveXObject("Msxml2.XMLHTTP");
					}catch(e){
						xmlreq=new ActiveXObject("Microsoft.XMLHTTP");
					}
				}
				//发送请求
				xmlreq.open("get","Cascade_user?time="+new Date().getTime());
				xmlreq.onreadystatechange=execute;
				xmlreq.send(null);
			}
			//接收响应的xml信息，生成table列表
			function execute(){
				if(xmlreq.readyState==4&&xmlreq.status==200){
					var xmlDoc=xmlreq.responseXML;
					var user=xmlDoc.getElementsByTagName("user");
					var userselect=document.getElementById("userselect");
					userselect.options.length=0;//清空select中的option选项
					//遍历servlet返回的数据，循环生成option
					for(var i=0;i<user.length;i++){
						var id=user[i].getElementsByTagName("id")[0].firstChild.data;
						var username=user[i].getElementsByTagName("username"	)[0].firstChild.data;
						userselect.options.add(new Option(username,id)	);
					}
				}
			}
		</script>
	</head>
	<body>
		<input type="button" value="load" onclick="sendRequest()"/>
		<hr/>
		<select id="userselect"></select>
	</body>
</html>
